(function() {
  'use strict';
  angular.module('controllers.dataManager.dataQualityApplication')
    .controller('businessForecastingCtrl', businessForecastingCtrl);

  function businessForecastingCtrl($scope, businessForecastingFactory, CoreService, CoreLoading) {
    $scope.initQuery = function() {
      CoreLoading.setState(true);
      var myEcharts = echarts.init(document.getElementById('predictionChart'));
      businessForecastingFactory.query(function(res) {
        if (res.data.state === '10000' && res.data.data.length >= 1) {
          CoreLoading.setState(false);
          var option = businessForecastingFactory.getArrayData(res.data.data);
          myEcharts.setOption(option);
        } else if (res.data.data.length === 0) {
          myEcharts && myEcharts.clear();
          CoreService.dialog('查询无数据');
        } else {
          myEcharts && myEcharts.clear();
          CoreService.dialog('查询错误');
        }
      });
    };
  }
})();
